<script type="text/javascript" src="<?= base_url() ?>resource/js/layer/layer.js"></script>
<!--top结束-->
<div class="mian">
    <div class="mian1">
        <div class="mian2">
            <!--left start-->
            <?php $this->load->view('defaults/common/left'); ?>
            <!--left end-->

            <!--right start-->
            <div class="right">
                <!--breadcrumb start-->
                <div class="righta"><?= $this->breadcrumb->generateHTML(); ?> </div>
                <!--breadcrumb end-->

                <!-- contents start -->
                <div id="contents">
                    <div id="ct_search">
                        <form action="<?= blang_url('wms/WriteOffList/need_list') ?>"  >
                            <table id="search_tb">
                                <tr>
                                    <td>
                                        SKU： <input type="text" name="sku" size="30" placeholder="sku">
                                        &nbsp;&nbsp;&nbsp;<?= lang('wms_ckh') ?>： <input type="text" name="ref_num" size="30" placeholder="<?= lang('wms_ckh') ?> ">&nbsp;&nbsp;&nbsp;
                                        <input type="submit" value=" <?= lang('wms_ss') ?>  ">
                                        <input type="button" onclick="selectedSubmit()" style="margin-left: 300px;" value="<?= lang('wms_panel_30029') ?>">
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                    <div class="ct_content">
                        <table class="tbwd800">
                            <tr>
                                <th><?= lang('wms_panel_30011') ?></th>
                                <th>PID</th>
                                <th><?= lang('wms_cppp') ?></th>
                                <th><?= lang('wms_panel_30030') ?></th>
                                <th><?= lang('wms_panel_30031') ?></th>
                                <th>sku</th>
                                <th><?= lang('wms_sl') ?></th>
                                <th><?= lang('wms_panel_30016') ?></th>
                                <th><?= lang('wms_mc') ?></th>
                                <th><input type='checkbox' id='checkall' name='checkall' /><?= lang('wms_panel_30018') ?></th>
                            </tr>
                            <?php
                            $urlParam = @http_build_query($this->input->get());
                            foreach ($receivingList as $row)
                            {
                                ?>
                                <tr align="left" class="moves">
                                    <td><?= $row['ref_num'] ?></td>
                                    <td><?= $row['pid'] ?></td>
                                    <td><?= $row['product_brand_id']; ?></td>
                                    <td><?= $row[''] ?></td>
                                    <td><?= $row[''] ?></td>
                                    <td><?= $row['sku'] ?></td>
                                    <td><?= $row['quantity'] ?></td>  
                                    <td><?= $row['whs_code'] ?></td>  
                                    <td><?= $row['products_name'] ?></td>
                                    <td><input type='checkbox' id='checkbox<?= $row['id'] ?>' name='checkid' value='<?= $row['id'] ?>' /><?= $row['p_status'] ?></td>
                                </tr>
<?php } ?>
                            <tr align="center">
                                <td colspan="7"><?= $pageShow ?></td>
                            </tr>
                        </table>
                    </div>
                </div>
                <!-- contents end -->
            </div>
            <!--right end-->
            <div class="clear"></div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $("#checkall").click(
    function(){
        if(this.checked){
            $("input[name='checkid']").prop('checked', true)
        }else{
            $("input[name='checkid']").prop('checked', false)
        }
    } 
);
    function selectedSubmit(){  
        var r=confirm("<?= lang('wms_tips_tsqrrk'); ?>");
        var tid= $("#tran_order").val();
        //loading层
        var LDindex;
        var ids=new Array()
        if(r){
            $("input[name='checkid']:checkbox:checked").each(function(){
                ids.push($(this).val());
            });
        }
        if(ids.length<1){
            alert('<?= lang('wms_tips_xzjl'); ?>');
            return false ;
        }
        $.ajax({
            type:'post',
            timeout:60000,
            data:{ids:JSON.stringify(ids)},
            url:"<?= blang_url('wms/WriteOff/add_package_with_items') ?>",
            beforeSend:function(XMLHttpRequest){
                LDindex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                })
            }, 
            success: function (rs) {
                layer.close(LDindex);  
                obj=JSON.parse(rs);
                console.log(obj)
                if(true==obj.success){
                    window.location.href='/sc/wms/PackegeList/detail/'+obj.id;
                }
                else{
                    alert(obj.msg);
                }
            },
            error: function (e, jqxhr, settings, exception) {
              
                layer.close(LDindex); 
            },
            complete : function(XMLHttpRequest,status){
                layer.close(LDindex); 
                if(status=='timeout'){
                    alert("<?= lang('wms_tips_timeout') ?>");
                }
            }
        });
    }
</script>
